<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('考试记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <input type="hidden" id="userId"  th:value="${userId}" name="params[userId]"/>
                            <li>
                                <p>学号：</p>
                                <input type="text" name="loginName"/>
                            </li>

                            <li>
                                <p>姓名：</p>
                                <input type="text" name="userName"/>
                            </li>

                            <li>
                                <p>班级：</p>
                                <select name="deptId">
                                    <option value="">所有</option>
                                    <option th:each="dept : ${mageDepts}" th:value="${dept.deptId}" th:text="${dept.deptName}" th:disabled="${dept.status == '1'}"></option>
                                </select>
                            </li>


                            <li class="select-time">
                                <p>考试时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginOprTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endOprTime]"/>
                            </li>
                            <!--<li>
                                <p>分数：</p>
                                <input type="text" name="score"/>
                            </li>-->

                            <li>
                                <p>分数：</p>
                                <input type="text"  id="startScore"  name="params[startScore]"/>
                                <span>-</span>
                                <input type="text"  id="endScore"  name="params[endScore]"/>
                            </li>

                            <li>
                                <p>考试用时：</p>
                                <input type="text" name="useTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="initTable()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>

                            <li>
                                <p>考试状态：</p>
                                <select name="testType">
                                    <option value="">所有</option>
                                    <option  value="1" text="补考" >补考</option>
                                    <option  value="0" text="正常" >正常</option>
                                    <option  value="2" text="未考" >未考</option>
                                </select>
                            </li>

                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="self:testrecord:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="self:testrecord:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="self:testrecord:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="self:testrecord:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('self:testrecord:edit')}]];
        var removeFlag = [[${@permission.hasPermi('self:testrecord:remove')}]];
        var prefix = ctx + "self/testrecord";
        var options;

        $(function() {
            options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "考试记录",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '考试记录id',
                    visible: false
                },
                {
                    field : 'loginName', 
                    title : '学号'
                },
                {
                  field : 'userName',
                  title : '姓名'
                },
                {
                    field : 'oprTime', 
                    title : '考试时间'
                },

                {
                    field : 'testMonth',
                    title : '所属月份'
                },
                {
                    title : '考试状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    field : 'score',
                    title : '分数'
                },
                {
                    field : 'deptId',
                    title : '班级ID'
                },
                {
                    field : 'deptName',
                    title : '班级'
                },
                {
                    field : 'useTime', 
                    title : '考试用时'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function initTable(){
            $.table.destroy();
            $.table.init(options);
        };

        /* 考试状态显示 */
        function statusTools(row) {
            if (row.testType == "1") {
                return '补考';
            } else if (row.testType == "0") {
                return '正常';
            } else {
                return '未考';
            }
        }
    </script>
</body>
</html>